package com.jms.web.controller.jms.service.impl;

import com.jms.common.filter.utils.DateUtils;
import com.jms.common.filter.utils.SecurityUtils;
import com.jms.web.controller.jms.domain.AttachFile;
import com.jms.web.controller.jms.mapper.AttachFileMapper;
import com.jms.web.controller.jms.service.IAttachFileService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 附件Service业务层处理
 * 
 * @author drx
 * @date 2024-04-29
 */
@Service
public class AttachFileServiceImpl implements IAttachFileService
{
    @Resource
    private AttachFileMapper attachFileMapper;

    /**
     * 查询附件
     * 
     * @param id 附件主键
     * @return 附件
     */
    @Override
    public AttachFile selectAttachFileById(Long id)
    {
        return attachFileMapper.selectAttachFileById(id);
    }

    /**
     * 查询附件列表
     * 
     * @param attachFile 附件
     * @return 附件
     */
    @Override
    public List<AttachFile> selectAttachFileList(AttachFile attachFile)
    {
        return attachFileMapper.selectAttachFileList(attachFile);
    }

    /**
     * 新增附件
     * 
     * @param attachFile 附件
     * @return 结果
     */
    @Override
    public int insertAttachFile(AttachFile attachFile)
    {
        attachFile.setCreateTime(DateUtils.getNowDate());
        attachFile.setCreateName(SecurityUtils.getLoginUser().getUser().getNickName());
        attachFile.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        return attachFileMapper.insertAttachFile(attachFile);
    }

    /**
     * 修改附件
     * 
     * @param attachFile 附件
     * @return 结果
     */
    @Override
    public int updateAttachFile(AttachFile attachFile)
    {
        attachFile.setUpdateTime(DateUtils.getNowDate());
        attachFile.setUpdateName(SecurityUtils.getLoginUser().getUser().getNickName());
        attachFile.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
        return attachFileMapper.updateAttachFile(attachFile);
    }

    /**
     * 批量删除附件
     * 
     * @param ids 需要删除的附件主键
     * @return 结果
     */
    @Override
    public int deleteAttachFileByIds(Long[] ids)
    {
        return attachFileMapper.deleteAttachFileByIds(ids);
    }

    /**
     * 删除附件信息
     * 
     * @param id 附件主键
     * @return 结果
     */
    @Override
    public int deleteAttachFileById(Long id)
    {
        return attachFileMapper.deleteAttachFileById(id);
    }
}
